#ifndef __FONTTYPE_TEST_H__
#define __FONTTYPE_TEST_H__

#include <windows.h>

class FontTypeTest
{
public:
    enum FontMode
    {
        FontMode_Nothing,
        FontMode_ClearType,
        FontMode_ClearType2,
        FontMode_Antialias
    };
    typedef struct tagFontBuffer
    {
        void* buf;
        int width;
        int height;
    } FontBuffer;
private:
    typedef struct tagGlyphInfo
    {
        DWORD glyphID;
        int left;
        int top;
        int width;
        int height;
    } GlyphInfo;
public:
    FontTypeTest();
    ~FontTypeTest();

    FontBuffer GetGlyphBuffer(wchar_t c, FontMode mode);
private:
    HFONT GetDefaultFont(int quality);
    void MeasureText(wchar_t c, GlyphInfo& glyphInfo);
    void TextOutToBuffer(HFONT hFont, char* buf, GlyphInfo glyphInfo);

    //mask to a8
    void* MaskToA8(unsigned int* src, GlyphInfo glyphInfo);
    char RGBToA8(unsigned int rgb);
    void* MaskBlack(char* mask, GlyphInfo glyphInfo);

    //mask to ClearType
    void* MaskToClearType(unsigned int* src, GlyphInfo glyphInfo);
private:
    FIXED FixedFromDouble(double d);
    unsigned int AlphaMulQ(unsigned int c, unsigned scale);
private:
    HDC m_hDC;
};

#endif